<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Warehouse extends BaseModel
{
    use HasFactory;
    protected $table = 'warehouse';
    // 允许批量操作的字段
    protected $fillable = ['warehouse_name','is_del','created_at','updated_at'];

    public function scopeSearch($query,$params)
    {
        if(!empty($params['warehouse_name'])){
            $query->where('warehouse_name',$params['warehouse_name']);
        }
        $query->where('is_del',2);
        return $query;
    }

    //货架
    public function goods_shelf(){
        return $this->hasMany(GoodsShelf::class,'warehouse_id','id');
    }
}
